package o;

import android.util.SparseArray;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.store.bean.user.GetPersonalInfoResBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;

@ApiDefine(uri = cbd.class)
@Singleton
public class cbf implements cbd {
    private AtomicBoolean ˊ = new AtomicBoolean(false);
    b ˋ = new b();
    private SparseArray<fkh> ˎ = new SparseArray();
    private long ॱ = 0;

    static class b implements cbc {
        int ˊ;
        int ˋ;
        String ˎ;
        int ॱ;

        b() {
        }

        public int ˎ() {
            return this.ˊ;
        }

        public String ˏ() {
            return this.ˎ;
        }

        public int ॱ() {
            return this.ॱ;
        }

        public int ˊ() {
            return this.ˋ;
        }
    }

    public fkd<cbc> ˏ(@NonNull String str) {
        fkh o_fkh = (fkh) this.ˎ.get(str.hashCode());
        if (o_fkh == null) {
            o_fkh = new fkh();
            this.ˎ.put(str.hashCode(), o_fkh);
        }
        return o_fkh.ˊ();
    }

    public void ˋ(cbc o_cbc) {
        bqx.ˊ("GetPersonInfoImpl", "updatePersonalInfo");
        this.ˋ.ˊ = o_cbc.ˎ();
        this.ˋ.ॱ = o_cbc.ॱ();
        this.ˋ.ˎ = o_cbc.ˏ();
        this.ˋ.ˋ = o_cbc.ˊ();
        ॱ();
    }

    public void ˋ() {
        bqx.ˊ("GetPersonInfoImpl", "logout");
        this.ˋ.ˊ = 0;
        this.ˋ.ॱ = 0;
        this.ˋ.ˎ = "";
        this.ˋ.ˋ = 0;
        this.ॱ = 0;
    }

    public cbc ˊ() {
        return this.ˋ;
    }

    public void ˏ() {
        bqx.ˊ("GetPersonInfoImpl", "getPersonInfoFromSrv");
        brc o_brc = (brc) fho.ˏ().ˋ("Base").ॱ(brc.class);
        if (o_brc != null) {
            if (ˎ()) {
                bqx.ˊ("GetPersonInfoImpl", "just access Srv: the info is valid");
            } else {
                this.ˊ.set(true);
                cgh o_cgh = new cgh();
                o_cgh.ˊ(1);
                ResponseBean responseBean = (ResponseBean) o_brc.ॱ(o_cgh);
                if ((responseBean instanceof GetPersonalInfoResBean) && responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                    GetPersonalInfoResBean getPersonalInfoResBean = (GetPersonalInfoResBean) responseBean;
                    this.ˋ.ˎ = getPersonalInfoResBean.ˎ();
                    this.ˋ.ॱ = getPersonalInfoResBean.ˊॱ();
                    this.ˋ.ˊ = getPersonalInfoResBean.ˊ();
                    this.ˋ.ˋ = getPersonalInfoResBean.ˋॱ();
                    if (this.ˊ.get()) {
                        this.ॱ = System.currentTimeMillis();
                        bqx.ˏ("GetPersonInfoImpl", "has finished get: " + this.ˊ.get());
                    }
                } else {
                    bqx.ˊ("GetPersonInfoImpl", "getPersonInfoFromSrv failed: rtnCode=" + responseBean.getRtnCode_() + ", rsp code =" + responseBean.getResponseCode());
                }
                this.ˊ.set(false);
            }
            ॱ();
        }
    }

    private boolean ˎ() {
        return System.currentTimeMillis() - this.ॱ < 1800000 || this.ˊ.get();
    }

    private void ॱ() {
        bqx.ˊ("GetPersonInfoImpl", "notifyObservers");
        int size = this.ˎ.size();
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < size; i++) {
            int keyAt = this.ˎ.keyAt(i);
            fkh o_fkh = (fkh) this.ˎ.get(keyAt);
            if (o_fkh != null) {
                o_fkh.ˋ(this.ˋ);
            } else {
                arrayList.add(Integer.valueOf(keyAt));
            }
        }
        if (arrayList.size() > 0) {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                this.ˎ.remove(((Integer) it.next()).intValue());
            }
        }
    }
}
